-
Notifications
You must be signed in to change notification settings - Fork 7.6k
LPIT Support on Zephyr #93167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
LPIT Support on Zephyr #93167
Conversation
FelixWang47831
commented
Jul 16, 2025
- Provide counter driver based on lpit driver from NXP mcux-sdk-ng
- Enable tests/drivers/counter/counter_nxp_lpit_api based on NXP mimxrt1180_evk, all channels test pass.
Hello @FelixWang47831, and thank you very much for your first pull request to the Zephyr project! |
3b743cb
to
d8eac6e
Compare
d8eac6e
to
dbfce5d
Compare
dbfce5d
to
50db653
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run the check compliance script, and explain why are you adding a test which is a copy paste of an existing test
drivers/counter/counter_mcux_lpit.c
Outdated
static int mcux_lpit_start(const struct device *dev) | ||
{ | ||
const struct mcux_lpit_config *config = dev->config; | ||
uint8_t channel_id = LPIT_CHANNEL_ID(dev); | ||
|
||
LOG_DBG("period is %d", mcux_lpit_get_top_value(dev)); | ||
LPIT_EnableInterrupts(config->base, (1U << channel_id)); | ||
LPIT_StartTimer(config->base, channel_id); | ||
return 0; | ||
} | ||
|
||
static int mcux_lpit_stop(const struct device *dev) | ||
{ | ||
const struct mcux_lpit_config *config = dev->config; | ||
int channel_id = LPIT_CHANNEL_ID(dev); | ||
|
||
LPIT_DisableInterrupts(config->base, (1U << channel_id)); | ||
LPIT_StopTimer(config->base, channel_id); | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to call these functions throughout various other parts of the driver where it is doing the same thing to save code size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has removed "LPIT_DisableInterrupts" from mcux_lpit_stop, it's unnecessary after stop timer.
However, LPIT_EnableInterrupts in mcux_lpit_start is necessary, there is test which start counter and set top value, verify whether top callback is executed in interrupt. I have never seen enable interrupt in set top value function among all vendor's driver, so I need to enable interrupt when starting timer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not clear to me at all why are you adding this test, the test looks at a glance almost exactly the same copy pasted as the generic counter_api test already in tree, and the commit message is empty here, and there is no comment with any description about the purpose of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has updated commit log to explain why adding this test:
This test is modified from tests/drivers/counter/counter_basic_api/src/
test_counter.c
The original test does not work for LPIT. For example, the hard code
channel 0 for counter_set_channel_alarm setting brings error for
lpit1_channel1, lpit2_channel3 and so on. And the setting alarm_cfgs.flags=0,
which means setting the relative ticks based on current ticks, brings
overflow errors, because LPIT is a count down timer which starts from top value.
Based on these limitation, In order to avoid modifying the original test
and bringing possible side effects to other platforms, a modified new
test was prepared here. In this test, COUNTER_ALARM_CFG_ABSOLUTE is set
for counter, and all channels specified in edvicetree file are test.
This test inclduing following tests:
- test_all_channels
- test_cancelled_alarm_does_not_expire
- test_set_top_value_with_alarm
- test_single_shot_alarm_notop
- test_single_shot_alarm_top
- test_valid_function_without_alarm
- test_set_top_value_without_alarm
1.Add dts bindings nxp,lpit-channel.yaml and nxp,lpit.yaml 2.Provide counter driver based on lpit driver from NXP mcux-sdk-ng Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
Add lpit1, lpit2, lpit3 and all of the channels information Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
1. Configure clock source for lpit3 for imxrt118x devices 2. Support lpit in clock driver Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
…on mimxrt1180_evk This test is modified from tests/drivers/counter/counter_basic_api/src/ test_counter.c The original test does not work for LPIT. For example, the hard code channel 0 for counter_set_channel_alarm setting brings error for lpit1_channel1, lpit2_channel3 and so on. And the setting alarm_cfgs.flags=0, which means setting the relative ticks based on current ticks, brings overflow errors, because LPIT is a count down timer which starts from top value. Based on these limitation, In order to avoid modifying the original test and bringing possible side effects to other platforms, a modified new test was prepared here. In this test, COUNTER_ALARM_CFG_ABSOLUTE is set for counter, and all channels specified in edvicetree file are test. This test inclduing following tests: - test_all_channels - test_cancelled_alarm_does_not_expire - test_set_top_value_with_alarm - test_single_shot_alarm_notop - test_single_shot_alarm_top - test_valid_function_without_alarm - test_set_top_value_without_alarm Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
f0b1a8a
to
4a4fa7e
Compare
|